Title: SQL BT (By-BKK) / 05 Select
Tags: Obsidian_to_Anki

Q: Which SQL clause is used to select all columns from a table?
A: SELECT *

Q: How do you select specific columns from a table in SQL?
A: SELECT column, another_column FROM mytable

Q: What does the WHERE clause do in SQL?
A: Filters rows based on a condition

Q: How do you order SQL results from high to low or low to high?
A: ORDER BY column ASC/DESC

Q: What does LIMIT do in a SQL query?
A: Limits the number of rows returned

Q: What SQL clause is used to skip a set number of rows before showing results?
A: OFFSET

Q: True or False: Positive latitudes are north of the equator.
A: True

Q: True or False: All cities in North America have negative longitudes.
A: True

Q: What is the table name for city population data in the review lesson?
A: north_american_cities

Q: What query lists all Canadian cities and their populations?
A: SELECT city, population FROM north_american_cities WHERE country = 'Canada';

Q: How do you list US cities from north to south by latitude?
A: SELECT city FROM north_american_cities WHERE country = 'United States' ORDER BY latitude DESC;

Q: How do you list cities west of Chicago, ordered from west to east?
A: SELECT city FROM north_american_cities WHERE longitude < -87.629798 ORDER BY longitude ASC;

Q: Which query gets the two largest cities in Mexico by population?
A: SELECT city FROM north_american_cities WHERE country = 'Mexico' ORDER BY population DESC LIMIT 2;

Q: What SQL lists the third and fourth largest cities in the US and population?
A: SELECT city, population FROM north_american_cities WHERE country = 'United States' ORDER BY population DESC LIMIT 2 OFFSET 2;

Q: Reverse card: SELECT city, population FROM north_american_cities WHERE country = 'Canada';
A: How do you list all Canadian cities and their populations?

Q: Reverse card: ORDER BY latitude DESC
A: Which clause is used to order US cities from north to south by latitude?

Q: Reverse card: SELECT city FROM north_american_cities WHERE longitude < -87.629798 ORDER BY longitude ASC;
A: How do you list cities west of Chicago, ordered from west to east?

Q: Reverse card: LIMIT and OFFSET
A: Which clauses are used to control which set of rows show in the query results when ordering by population?